package com.hzy.sharding.config;

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import lombok.Getter;
import org.apache.shardingsphere.api.config.sharding.strategy.ShardingStrategyConfiguration;

@Getter
public class ModuloTableShardingAlgorithm implements ShardingStrategyConfiguration {

    private final String shardingColumn;

    private final String algorithmExpression;

    public ModuloTableShardingAlgorithm(final String shardingColumn, final String algorithmExpression) {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(shardingColumn), "ShardingColumn is required.");
        Preconditions.checkArgument(!Strings.isNullOrEmpty(algorithmExpression), "AlgorithmExpression is required.");
        this.shardingColumn = shardingColumn;
        this.algorithmExpression = algorithmExpression;
    }
}
